package com.metagurukul.informer.service;

import java.sql.SQLException;
import java.util.List;
import com.metagurukul.informer.dao.SearchDAO;
import com.metagurukul.informer.valueObjects.Questions;

public class SearchService {

	private String searchString;
	public SearchService() {
		searchString = "";
	}
	public SearchService(String searchString) {
		this.searchString = searchString;
	}
	/**
	 * search the question according to phrase
	 * @return the list of question details
	 * @throws SQLException
	 */
	public List<Questions> questionList()  throws SQLException{
		String str[] = searchString.split(" ");
		String searchString = "%";
		for(String temp:str){ 
			searchString = searchString+temp+"%";
		}
		SearchDAO searchdao = new SearchDAO();
		return searchdao.findQuestions(searchString);
	}
}
